<template>
  <div id="search">
    <div class="search-wrap">
      <div class="search-input">
        <i class="fa fa-search"></i><input type="text" />
      </div>
    </div>
    <ul class="search-content">
      <li v-for="(item, index) in results" :key="index">
        <h4 class="search-title">电影/电视剧/综艺</h4>
        <div class="search-body">
          <div class="img">
            <img :src="item.img" alt="" />
          </div>
          <div class="txt">
            <h2>{{ item.name }}</h2>
            <p>{{ item.actors }}</p>
            <p>{{ item.nums }}</p>
          </div>
          <span>8.9</span>
        </div>
      </li>
    </ul>
  </div>
</template>
<script>
import func from "vue-editor-bridge";
export default {
  name: "Search",
  data() {
    return {
      comingPlayData: [],
      publicPath: process.env.BASE_URL,
    };
  },
  methods: {
    getAll() {
      var that = this;
      function getComingPlayData() {
        return axios.get("/mock/comingPlayData.json");
      }
      function getNowPlayData() {
        return axios.get("/mock/nowPlayData.json");
      }
      axios.all([getComingPlayData(), getNowPlayData()]).then(
        axios.spread(function (data1, data2) {
          that.allData = [
            ...data1.data.comingPlayData,
            ...data2.data.nowPlayData,
          ];
          console.log(that.allData);
        })
      );
    },
  },
  created() {
    this.getAll();
  },
  computed: {
    results() {
      if (this.searchStr) {
        return this.allData.filter((item) =>
          item.name.includes(this.searchStr)
        );
      } else {
        return [];
      }
    },
  },
};
</script>
<style scoped>
.search-wrap {
  width: 100%;
  height: 50px;
  background-color: #f0f0f0fc;
  overflow: hidden;
}
.search-input {
  display: flex;
  width: 96%;
  height: 30px;
  border: 1px solid #ccc;
  background-color: #fff;
  margin: 10px auto;
  line-height: 30px;
  border-radius: 5px;
  overflow: hidden;
}
i.fa-search {
  margin: 0 5px;
  line-height: 30px;
}
.search-input input {
  flex: 1;
  outline: none;
  border: none;
}
.search-content {
  width: 100%;
}
.search-title {
  width: 100%;
  height: 50px;
  border-bottom: 1px solid #ccc;
  color: rgb(167, 160, 160);
  line-height: 50px;
  padding-left: 10px;
  font-size: 18px;
}
.search-body {
  display: flex;
  padding: 10px;
  border-bottom: 1px dotted #ccc;
}
.img img {
  width: 80px;
}
.txt {
  flex: 1;
  margin-left: 15px;
}
.txt h2 {
  font-weight: 400;
}
.txt p {
  font-size: 16px;
  margin: 5px 0;
}
.search-body span {
  color: #f90;
  font-size: 20px;
}
</style>
